home *** CD-ROM | disk | FTP | other *** search
- /* NAME:
- VBL Task.c
-
- WRITTEN BY:
- Dair Grant
-
- DESCRIPTION:
- This file contains a code resource to be installed as a VBL task.
-
- NOTES:
- We move the mouse cursor in a tight circle when the mouse button is
- down. If the Caps-Lock key is on, we have no effect.
-
- ___________________________________________________________________________
- */
- //=============================================================================
- // Include files
- //-----------------------------------------------------------------------------
- #include <Retrace.h>
- #include "A4Stuff.h"
- #include "SetupA4.h"
- #include "CM Constants.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // Private defines
- //-----------------------------------------------------------------------------
- #define kRadius 5 // Actual radius is (1+2+...+(kRadius-1))+(kRadius/2)
- #define kTimeDelay 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // Global Variables
- //-----------------------------------------------------------------------------
- extern Boolean CrsrNew : 0x8CE; // Low memory globals
- extern Point mTemp : 0x828;
- extern Point RawMouse : 0x82C;
-
- Boolean gAlreadyRan = false;
- int gVx,gVy;
- Boolean gXIncreasing, gYIncreasing;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // Private function prototypes
- //-----------------------------------------------------------------------------
- void main(VBLTask *theVBL : __D0);
- Boolean CapsKeyDown(void);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // main : Entry point to our code resource.
- //-----------------------------------------------------------------------------
- // Note : We spin the mouse cursor round in a circle, unless the Caps
- // Lock key is on.
- //-----------------------------------------------------------------------------
- void main(VBLTask *theVBL : __D0)
- { long oldA4;
-
-
- // Set up A4
- #ifndef powerc
- oldA4 = SetCurrentA4();
- #endif
-
-
-
- // If we've not already been called, do our one time initialisation stuff
- if (!gAlreadyRan)
- {
- gVx = kRadius;
- gVy = 0;
- gXIncreasing = false;
- gYIncreasing = true;
- gAlreadyRan = true;
- }
-
-
- // If the mouse button is down, and the caps lock key isn't - rotate
- if (Button() && !CapsKeyDown())
- {
- RawMouse.h += gVx;
- mTemp.h += gVx;
- RawMouse.v += gVy;
- mTemp.v += gVy;
-
- gVx += gXIncreasing ? 1 : -1;
- gVy += gYIncreasing ? 1 : -1;
-
- gXIncreasing = (gVx == kRadius) ? false : (gVx == -kRadius) ? true : gXIncreasing;
- gYIncreasing = (gVy == kRadius) ? false : (gVy == -kRadius) ? true : gYIncreasing;
-
- CrsrNew = true;
- }
-
-
-
- // Reset our timer, and restore A4 and return
- theVBL->vblCount = kTimeDelay;
- #ifndef powerc
- SetA4(oldA4);
- #endif
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //=============================================================================
- // CapsKeyDown : Returns true if the Caps-lock key is down.
- //-----------------------------------------------------------------------------
- Boolean CapsKeyDown(void)
- { unsigned char theKeys[16];
- short theCapsKey = 57;
-
-
- GetKeys((void *) theKeys);
- return((theKeys[theCapsKey >> 3] >> (theCapsKey & 7)) & 1);
- }
-